package familytree.yu.com.sso.enums;

/**
 * @Author: yuyunbo
 * @Date: 2021/2/22 22:33
 * @Description:
 */
public enum ErrorCodeEnum implements CodeBaseEnum {

    /**
     * 全局通用
     */
    ER1(1001, "注册失败"),
    ER2(1002, "用户名或密码错误"),

    ER5(1005, "授权登录失败"),
    ER6(1006, "用户名或密码不能为空"),
    ER8(1008, "授权登录异常"),
    ER9(1009, "账户已被禁用"),
    ;

    private int code;

    private String msg;

    ErrorCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * Gets enum.
     *
     * @param code the code
     * @return the enum
     */
    public static ErrorCodeEnum getEnum(int code) {
        for (ErrorCodeEnum ele : ErrorCodeEnum.values()) {
            if (ele.code() == code) {
                return ele;
            }
        }
        return null;
    }

    /**
     * 获取枚举编码
     *
     * @return
     */
    @Override
    public int code() {
        return 0;
    }

    /**
     * 获取编码对应的描述
     *
     * @return
     */
    @Override
    public String msg() {
        return null;
    }
}
